﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using HCMServices.DTO;

namespace HCMServices.DAO
{
    public class DetailServiceDAO
    {
        private MyDataContext db;

        public DetailServiceDAO(string connectString)
        {
            db = new MyDataContext(connectString);
        }

        public DetailServiceDTO Search(int serviceId)
        {
            DetailServiceDTO servicedtl = new DetailServiceDTO();

            var query = from CHITIETDICHVU ser in db.DetailService
                        where ser.MaChiTiet == serviceId
                        select ser;
            if (query != null)
            {
                CHITIETDICHVU s = query.First();
                servicedtl.ServiceID = s.MaChiTiet;
                if (s.Ten != null)
                    servicedtl.Name = s.Ten;
                if (s.GiaTien != 0)
                    servicedtl.Cost = s.GiaTien;
                if (s.ChuThich != null)
                    servicedtl.Comment = s.ChuThich;
            }

            return servicedtl;
        }
    }
}
